package ruleconstruct;

import pojo.LogBean;
import pojo.RuleAutomicParam;
import pojo.RuleParam;

import java.util.ArrayList;
import java.util.HashMap;

public class Rulesimulator {
    public static  RuleParam   createrule(){
        RuleParam ruleParam1 = new RuleParam();
        ruleParam1.setRuleId("123456");




        /**
         * 构建触发条件
         */

        RuleAutomicParam trigger = new RuleAutomicParam();
        String Eventid = "W";
        trigger.setEventId(Eventid);
        ruleParam1.setTriggerparam(trigger);


        /**
         *画像条件
         */
        //99                      column=f:84k, timestamp=1621604818884, value=v99
        //99                      column=f:85k, timestamp=1621604818884, value=v94
        HashMap<String, String> userprofileproperties = new HashMap<>();
        userprofileproperties.put("84k", "v99");
        userprofileproperties.put("85k", "v94");
        ruleParam1.setUserProfileParam(userprofileproperties);



        /**
         * 行为事件条件 A[p1=v2,p2=v3]  ==8
         */
        RuleAutomicParam param1 = new RuleAutomicParam();
        param1.setEventId("B");
        HashMap<String, String> paramProps1 = new HashMap<>();
        paramProps1.put("p1", "v1");
        param1.setProperties(paramProps1);
        param1.setCount(2);
        param1.setStarttime(-1L);
        param1.setEndtime(-1L);

        RuleAutomicParam param2 = new RuleAutomicParam();
        param2.setEventId("D");
        HashMap<String, String> paramProps2 = new HashMap<>();
        paramProps2.put("p2", "v3");
        param2.setProperties(paramProps2);
        param2.setCount(2);
        param2.setStarttime(-1L);
        param2.setEndtime(-1L);

        ArrayList<RuleAutomicParam> ruleParams = new ArrayList<>();
        ruleParams.add(param1);
        ruleParams.add(param2);
        ruleParam1.setUserActionParam(ruleParams);



        /**
         * 行为序列事件
         */
        // 构造2个规则原子条件
        RuleAutomicParam userActionSeq1 = new RuleAutomicParam();
        userActionSeq1.setEventId("A");
        userActionSeq1.setStarttime(-1L);
        userActionSeq1.setEndtime(-1L);
        HashMap<String, String> userActionSeqproperties1 = new HashMap<>();
        userActionSeqproperties1.put("p1", "v2");
        userActionSeq1.setProperties(userActionSeqproperties1);

        RuleAutomicParam userActionSeq2 = new RuleAutomicParam();
        userActionSeq2.setEventId("C");
        userActionSeq2.setStarttime(-1L);
        userActionSeq2.setEndtime(-1L);
        HashMap<String, String> userActionSeqproperties2 = new HashMap<>();
        userActionSeqproperties2.put("p4", "v6");
        userActionSeq2.setProperties(userActionSeqproperties2);
//
//        RuleAutomicParam param3 = new RuleAutomicParam();
//        param3.setEventId("E");
//        HashMap<String, String> paramProps3 = new HashMap<>();
//        paramProps3.put("p5", "v8");
//        param3.setProperties(paramProps3);

        ArrayList<RuleAutomicParam> ruleParamsList = new ArrayList<>();
        ruleParamsList.add(userActionSeq1);
        ruleParamsList.add(userActionSeq2);
//        ruleParams.add(param3);
        ruleParam1.setUserActionsequenceParam(ruleParamsList);

        return ruleParam1;
    }
}
